package com.job.admin.audit.service.impl;

import com.job.admin.audit.service.AuditAvatarService;
import com.job.admin.audit.service.AuditCompanyService;
import com.job.admin.audit.service.AuditPostsService;
import com.job.admin.audit.service.AuditService;
import com.job.client.common.result.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class AuditServiceImpl implements AuditService {
    @Autowired
    private AuditAvatarService auditAvatarService;
    @Autowired
    private AuditCompanyService auditCompanyService;
    @Autowired
    private AuditPostsService auditPostsService;
    @Override
    public ResponseResult getAuditInfo(String userId) {
        ResponseResult avatar = auditAvatarService.getAuditInfo(userId);
        ResponseResult company = auditCompanyService.getAuditInfo(userId);
        ResponseResult posts = auditPostsService.getAuditInfo(userId);
        if(avatar.getCode() != 200){
            return avatar;
        }
        if(company.getCode() != 200){
            return company;
        }
        if(posts.getCode() != 200){
            return posts;
        }
        Map<String,Object> data = new HashMap<>();
        data.put("avatar",avatar.getData());
        data.put("company",company.getData());
        data.put("posts",posts.getData());
        return ResponseResult.OkResult(data);
    }
}
